﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "IModelingOperation.h"
#include "GcmpModel.h"

namespace gcmp
{
    /// \brief 通用的造型操作接口
    /// 通过转调 CommonModelingOperationImpl 实现
    class GCMP_MODEL_EXPORT CommonModelingOperation :public NdbObjectSchematic, public IModelingOperation
    {
    private:
        DBOBJECT_DATA_BEGIN_AND_QUICK_CAST_FROM(gcmp, CommonModelingOperation, gcmp::NdbObjectSchematic, 1E64A494 - 7016 - 4F91 - BDFD - 2CF78CC02E17 , gcmpmodel, gcmp::IModelingOperation)
            DATA(OwnerPtr<gcmp::IModelingOperation>, CommonModelingOperationImpl)
            DATA_TRANSIENT(IElement*, pOwnerElement)
        DBOBJECT_DATA_END
    public:
        virtual ~CommonModelingOperation();

        /// \brief   造型操作的执行函数
        ///
        /// \param pElement   IElement的指针
        /// \param pGraphicsElementShape  IGraphicsElementShape的指针
        /// \return  true 成功;false，失败
        virtual bool Execute(IElement* pElement, IGraphicsElementShape* pGraphicsElementShape) override;

        /// \brief   设置造型操作Id
        ///
        /// \param operationId   造型操作Id
        /// \return 
        virtual void SetOperationId(Int32 operationId) override;

        /// \brief   获取造型操作Id
        ///
        /// \return 造型操作Id
        virtual Int32 GetOperationId()const override;

        /// \brief   重置造型操作
        ///
        virtual void Reset() override;

        /// \brief   创建GraphicsNodeId的查询类
        ///
        /// \param pElement  IElement的指针
        /// \return 
        virtual OwnerPtr<IGraphicsNodeIdAsker> CreateGraphicsNodeIdAsker(IElement* pElement) override;

        /// \brief   判断id是否是面类型
        /// 
        /// \param id  面的Id
        /// \return  true 成功;false，失败
        virtual bool IsFace(int id)const override;

        /// \brief   判断id是否是边类型
        ///  
        /// \param id 边的Id
        /// \return true 成功;false，失败
        virtual bool IsEdge(int id)const override;

        /// \brief    获取该Operation,父子关系Id的映射
        /// 
        /// \return  映射关系
        virtual const std::unordered_map<int, int>& GetChildToParentIdMap()const override;


    public: //实现NdbObject接口
        virtual NdbObject* GetTopOwnerObject() const override;
        virtual bool SetOwnerElement(IElement* pOwnerElement) override;
        virtual IElement* GetOwnerElement() override { return m_pOwnerElement; }
        virtual const IElement* GetOwnerElement() const override { return m_pOwnerElement; }
    };
}


